/******************************************************************************
 *	Author: 	Williams, Jacob (williamsj@msoe.edu)
 *	Class:		CE-3910
 *	Assignment:	Milestone 2
 *	Instructor:	Dr. Barnekow
 *****************************************************************************/

#ifndef UART_H
#define UART_H

#include <stdint.h>
#include <avr/io.h>

#define BAUDRATE 9600
#define CPU_FREQUENCY 16000000
#define UBBR_VALUE (CPU_FREQUENCY / ( 16 * 1000000 * BAUDRATE)) - 1

/**
 * Initializes the UART with the following settings:
 * Baud Rate:               9600
 * Transmitter:             Enabled
 * Send Complete ISR:       Disabled
 * Receiver:                Enabled
 * Receive Complete ISR:    Disabled
 * Character Size:          8 bits
 * Stop Bits:               2
 * Parity:                  Odd
 */
void uartInit(int Baudrate, int CPUclockFreq);

/**
 * Sends a character with the UART
 * @param data The character to be sent
 */
void uartPutc(char a);

/**
 * Waits for a character to be received through the UART. NOTE: This function
 * is blocking and the system will hang until a character is received.
 * @return The character recieved on the UART
 */
char uartGetc(void);

#endif
